<template>
    <div>
        <van-nav-bar title="编辑地址" left-text="返回" left-arrow @click-left="$router.back()" />
        <van-address-edit :area-list="areaList" :address-info="adddressInfo" show-delete show-set-default area-placeholder
            :area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave" @delete="onDelete" />
    </div>
</template>

<script>
import { areaList } from '@vant/area-data';
export default {
    name: "EditAddress",
    data() {
        return {
            areaList,
            searchResult: [],
            adddressInfo: {}
        };
    },
    mounted(){
        this.init()
    },
    methods: {
        init(){
            this.adddressInfo = this.$route.query.editAddress
        },
        async onSave(content) {
            console.log(content)
            let res = await this.$store.dispatch('updateAddress', {
                id: content.id,
                address: content.province + content.city + content.county + content.addressDetail,
                name: content.name,
                tel: content.tel,
                isDefault: content.isDefault == true ? 1 : 2,
                county: content.county,
                province: content.province,
                city: content.city,
                addressDetail: content.addressDetail,
                areaCode: content.areaCode,
            })
            if (res.success) this.$toast.success(res.message)
            else this.$myFun.resError(res.message)
        },
        onDelete() {
            Toast('delete');
        },


    },
}
</script>

<style></style>